<?php $this->_extends('../_layouts/blank_layout'); ?>
<?php $this->_block('contents'); ?>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.js"></script>
<link type="text/css" href="<?=Q::ini('custom_system/base_url')?>css/prettyphoto.css" rel="stylesheet" />
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.prettyphoto.js"></script>
<script type="text/javascript">
$(function(){
	$("a[rel^='pretty_photo']").prettyPhoto({theme:'facebook'});
});
</script>
<table class="table_form">
	<tr>
		<th><?=Helper_BSS_Normal::getIniOne('purchase_order_type', 'value', $purchase_order['type'], 'name')?></th>
		<td><?=$purchase_order['number']?></td>
		<th>日期</th>
		<td><?=$purchase_order['purchase_time']?></td>
	</tr>
	<tr>
		<th>经手人员</th>
		<td><?=$purchase_order['purchase_user_name']?></td>
		<th>结款类型</th>
		<td><?=Helper_BSS_Normal::getIniOne('purchase_order_payment_type', 'value', $purchase_order['payment_type'], 'name')?></td>
	</tr>
	<tr>
		<th>所在仓库</th>
		<td><?=$purchase_order['warehouse_name']?></td>
	</tr>
	<tr>
		<th>备注</th>
		<td><textarea rows="3" cols="70" disabled="disabled"><?=$purchase_order['notes']?></textarea></td>
	</tr>
</table>
<table width="100%" class="list_table">
<tr>
	<th width="70">产品编号</th>
	<th>产品名称</th>
	<th width="50">采购状态</th>
	<th width="50">销售状态</th>
	<th width="40">库存</th>
	<th width="40">待发</th>
	<th width="50">警告库存</th>
	<th width="50">安全库存</th>
	<th width="40">录单数</th>
	<th width="50">采购数</th>
	<th width="50">批发数</th>
	<th width="40">预计数</th>
	<th width="50">预计单价</th>
	<th width="50">资料价</th>
	<th width="100">预计供应商</th>
	<th width="40">实际数</th>
	<th width="50">实际单价</th>
	<th width="100">实际供应商</th>
	<th width="100">采购原因</th>
	<th>备注</th>
</tr>
<?$budget_quantity = $actual_quantity = 0;?>
<?foreach ($item as $i):?>
<?php
	$budget_quantity += $i['budget_quantity'];
	$actual_quantity += $i['actual_quantity'];
?>
<tr>
	<td>
		<a target="_blank" href="<?=url('Product::Warehouse/Edit', array('id'=>$i['product_basic_id']))?>"><?=$i['product_number']?></a>
		<?if ($i['pic_url']):?>
			<?$pretty_photo_number = 0;?>
			<?foreach ($i['pic_url'] as $pp):?>
			<a rel="pretty_photo[<?=$i['id']?>]" href="<?=$pp?>"><?if(!$pretty_photo_number):?><span class="img_icon"></span><?endif;?></a>
			<?$pretty_photo_number = 1;?>
			<?endforeach;?>
		<?endif;?>
	</td>
	<td align="left"><?=$i['name']?></td>
	<td><font color="#<?=Helper_BSS_Normal::getIniOne('product_purchase_status', 'value', $i['purchase_status'], 'color')?>"><?=Helper_BSS_Normal::getIniOne('product_purchase_status', 'value', $i['purchase_status'], 'name')?></font></td>
	<td><font color="#<?=Helper_BSS_Normal::getIniOne('product_sales_status', 'value', $i['sales_status'], 'color')?>"><?=Helper_BSS_Normal::getIniOne('product_sales_status', 'value', $i['sales_status'], 'name')?></font></td>
	<td><?=$i['stock_quantity']?></td>
	<td><?=$i['sold_quantity']?></td>
	<td><?=$i['warning_quantity']?></td>
	<td><?=$i['safe_quantity']?></td>
	<td><?=$i['purchase_budget_quantity']?></td>
	<td><?=$i['purchase_quantity']?></td>
	<td><?=$i['wholesale_quantity'] ?></td>
	<td><?=$i['budget_quantity']?></td>
	<td><?=$i['budget_price']?sprintf('%.2f', $i['budget_price']):''?></td>
	<td><?=$i['purchase_price']?sprintf('%.2f', $i['purchase_price']):''?></td>
	<td><?=$i['budget_provider_name']?></td>
	<td><?=$i['actual_quantity']?></td>
	<td><?=$i['actual_price']?sprintf('%.2f', $i['actual_price']):''?></td>
	<td><?=$i['actual_provider_name']?></td>
	<td><?=Helper_BSS_Normal::getIniOne('purchase_order_item_reason', 'value', $i['reason'], 'name')?></td>
	<td><?=$i['notes']?></td>
</tr>
<?endforeach;?>
<tr>
	<td colspan="11" align="right"><b>总计：</b></td>
	<td><b><?=$budget_quantity?></b></td>
	<td><b><?=sprintf('%.2f', $purchase_order['budget_amount'])?></b></td>
	<td colspan="2"></td>
	<td><b><?=$actual_quantity?></b></td>
	<td><b><?=sprintf('%.2f', $purchase_order['actual_amount'])?></b></td>
	<td colspan="3"></td>
</tr>
</table>
<?php $this->_endblock();?>